Learn R Programming

otel (version 0.2.0)

Zero Code Instrumentation: Zero Code Instrumentation

Description

otel supports zero-code instrumentation (ZCI) via the OTEL_INSTRUMENT_R_PKGS environment variable. Set this to a comma separated list of package names, the packages that you want to instrument. Then otel will hook up base::trace() to produce OpenTelemetry output from every function of these packages.

Arguments

Value

Not applicable.

Details

By default all functions of the listed packages are instrumented. To instrument a subset of all functions set the OTEL_INSTRUMENT_R_PKGS_<PKG>_INCLUDE environment variable to a list of glob expressions. <PKG> is the package name in all capital letters. Only functions that match to at least one glob expression will be instrumented.

To exclude functions from instrumentation, set the OTEL_INSTRUMENT_R_PKGS_<PKG>_EXCLUDE environment variable to a list of glob expressions. <PKG> is the package name in all capital letters. Functions that match to at least one glob expression will not be instrumented. Inclusion globs are applied before exclusion globs.

Caveats

If the user calls base::trace() on an instrumented function, that deletes the instrumentation, since the second base::trace() call overwrites the first.

See Also

Environment Variables

Other OpenTelemetry trace API: end_span(), is_tracing_enabled(), local_active_span(), start_local_active_span(), start_span(), tracing-constants, with_active_span()

Examples

Run this code
# To run an R script with ZCI:
# OTEL_TRACES_EXPORTER=http OTEL_INSTRUMENT_R_PKGS=dplyr,tidyr R -q -f script.R

Run the code above in your browser using DataLab